<?php
class SearchUpdateVersionAction extends Action {
	//获取可更新的软件包
	public function searchUpdateVersion() {
		$list = M('update_version')->where("version_type='oceanversion'")->select();
		foreach ($list as $k => $v) {
			$arr[$v['publish_time']] = array(
				'date' => $v['publish_time'],
				'title' => $v['version_name'],
				'version' => $v['version_number'],
				'zip' => $v['filename']
			);
		}
		echo json_encode($arr);
	}
	
	//获取可更新的应用软件包
	public function searchUpdateAppVersion() {
		$arr = array();
		foreach ($_POST as $k => $v) {
			$k = str_replace('&', '', str_replace('amp;','',$k));
			$data['version_type'] = 'appversion';
			$data['appname'] = $k;
			$data['history_versionnumber'] = $v;
			$findUpdateVersion = M('update_version')->where($data)->find();
			if(!empty($findUpdateVersion)) {
				$arr[$k] = array(
					'date' => $findUpdateVersion['publish_time'],
					'title' => $findUpdateVersion['version_name'],
					'version' => $findUpdateVersion['version_number'],
					'zip' => $findUpdateVersion['filename']
				);
			}
		}
		echo serialize($arr);
	}
	
	//获取可更新的插件软件包
	public function searchUpdatePluginVersion() {
		$arr = array();
		foreach ($_POST as $k => $v) {
			$k = str_replace('&', '', str_replace('amp;','',$k));
			$data['version_type'] = 'pluginversion';
			$data['pluginname'] = $k;
			$data['history_versionnumber'] = $v;
			$findUpdateVersion = M('update_version')->where($data)->find();
			if(!empty($findUpdateVersion)) {
				$arr[$k] = array(
					'date' => $findUpdateVersion['publish_time'],
					'title' => $findUpdateVersion['version_name'],
					'version' => $findUpdateVersion['version_number'],
					'zip' => $findUpdateVersion['filename']
				);
			}
		}
		echo serialize($arr);
	}
}
?>